<%namespace file="dbi.inc" import="*" />
#ifndef _DBI_${_macro(fullname)}_H_
#define _DBI_${_macro(fullname)}_H_
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include "ayoo.h"

/**
 * @brief data-storage for ${tablename} 
 * @remarks generated-code.
 */
class ${classname}:public AYOO::BaseRow
{
public:
% for col_name, col in columns.items():
	${_struct_field(col)};
% endfor
public:
	${classname}()
	{
% for col_name, col in columns.items():
%	if 'i32|ui32|i64|ui64'.find(col.Type)>=0:
		this->${col.getFixName()} = 0;
% 	endif
% endfor
	}

	void Escape()
	{
% for col_name, col in columns.items():
%	if 'string'==col.Type:
		AYOO::MySQLWrap::EscapeString(this->${col.getFixName()});
% 	endif
% endfor
	}
};

/**
 * @brief data-DBI for ${tablename} 
 * @remarks generated-code.
 */
class DBI${classname}:public AYOO::BaseDBI
{
public:
	DBI${classname}(const std::string &sHost, uint32_t iPort, const std::string &sUser, const std::string &sPswd)
	: AYOO::BaseDBI( sHost, iPort, sUser, sPswd)
	{
	}

	DBI${classname}(const AYOO::Config& conf)
	: AYOO::BaseDBI(conf, "DB_HOST", "DB_PORT", "DB_USER", "DB_PSWD" )
	{
	}

	int32_t Insert(${classname} &in_${classname});
	int32_t SelectOne(${_pks_params(columns)}, ${classname} &out_${classname});
	int32_t Select(const std::string &sCondition, uint32_t iStart, uint32_t iLimit, std::vector<${classname}> &outlist_${classname});
	int32_t Count(const std::string &sCondition);
	int32_t UpdateOne(${_pks_params(columns)}, ${classname} &in_${classname});
	int32_t Update(const std::string &sCondition, ${classname} &in_${classname});
	int32_t DeleteOne(${_pks_params(columns)});
	int32_t Delete(const std::string &sCondition);

};

#endif /*_DBI_${_macro(fullname)}_H_*/

